/**
 * 该文件用于定义动作创建函数
 */

import { CHANGE_COUNT, DECREMENT, INCREMENT } from "./actionTypes";

export const add = () => ({ type: INCREMENT, payload: "掌握三" });
export const jian = () => ({ type: DECREMENT, payload: "里斯" });
export const change = (payload = 100) => ({
  type: CHANGE_COUNT,
  payload: payload,
});

export const setToken = (payload) => ({ type: "SET_TOKEN", payload });

export const asyncAdd = () => (dispatch) => {
  setTimeout(() => {
    // 异步做完之后，再主动派发一个普通动作
    dispatch(add());
  }, 1000);
};
